﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using Uber.Storage;
using Uber.Messages;
using Uber.HabboHotel.GameClients;
using Uber.HabboHotel.Pathfinding;
using Uber.HabboHotel.Rooms;

namespace Uber.HabboHotel.Items.Interactors
{
    class InteractorScoreboard : FurniInteractor
    {
        public override bool OnPlace(GameClient Session, RoomItem Item) { return true; }
        public override void OnRemove(GameClient Session, RoomItem Item) { }

        public override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            if (!UserHasRights)
            {
                return;
            }

            int NewMode = 0;

            try
            {
                NewMode = int.Parse(Item.ExtraData);
            }
            catch (Exception) { }

            if (Request == 0)
            {
                if (NewMode <= -1)
                {
                    NewMode = 0;
                }
                else if (NewMode >= 0)
                {
                    NewMode = -1;
                }
            }
            else if (Request >= 1)
            {
                if (Request == 1)
                {
                    NewMode--;

                    if (NewMode < 0)
                    {
                        NewMode = 0;
                    }
                }
                else if (Request == 2)
                {
                    NewMode++;

                    if (NewMode >= 100)
                    {
                        NewMode = 0;
                    }
                }
            }

            Item.ExtraData = NewMode.ToString();
            Item.UpdateState();
        }
    }
}
